package main

import "fmt"

//结构体
type Point struct {
	x int
	y int
}

//结构体
type Rect struct {
	leftUp, rightDown Point
}

//结构体
type Rect2 struct {
	leftUp, rightDown *Point
}

func main() {
	// r1 := Rect{Point{1, 2}, Point{3, 4}}
	// fmt.Printf("r1.leftUp.x 地址为%p r1.leftUp.y 地址为%p\n r1.rightDown.x 地址为%p r1.rightDown.y 地址为%p",
	// 	&r1.leftUp.x, &r1.leftUp.y, &r1.rightDown.x, &r1.rightDown.y)

	//r2 有两个 *Point类型，这两个*Point类型的本身地址也是连续的
	//但是他们只想的地址不一定是连续的
	r2 := Rect2{&Point{10, 20}, &Point{30, 40}}
	//打印地址
	fmt.Printf("r2.leftUp本身地址为%p r2.rightDown本身地址为%p \n ",
		&r2.leftUp, &r2.rightDown)

	//他们指向的地址不一定是连续的
	fmt.Printf("r2.leftUp本身地址为%p r2.rightDown本身地址为%p \n ",
		r2.leftUp, r2.rightDown)
}
